/**
 * Copyright (C) 2016 Hyphenate Inc. All rights reserved.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Keep;
import org.greenrobot.greendao.annotation.Transient;

import java.util.Date;
import java.util.List;

import org.greenrobot.greendao.annotation.Generated;

//import com.hyphenate.chat.EMContact;
//import com.srwl.easeui.utils.EaseCommonUtils;

@Entity
public class User implements Parcelable {
    @Id
    private String uId;
    private String username;
    @Transient//不在表中创建这个字段
    private String password;
    @Transient
    private String payPassword;//支付密码

    @Transient
    private Integer payLimit;//免密支付的额度

    private String nick;
    private String avatar;
    private String area;
    @Transient
    private List<OrderReceiveInfo> OrderReceiveInfoList; //收货地址等信息
    private Integer gender;
    private String phone;
    private String email;
    private Date created;
    private Date updated;
    private Date birthday;
    private Double donationAmount;
    private Integer status;

    private Integer type;
    @Transient
    private String token;
    @Transient
    private Double balance;

    @Transient
    private Double deposit;//用户保证金
    @Transient
    private LatLng latLng;
    @Transient
    private String aliUid;
    @Transient
    private String aliAccount;
    @Transient
    private Long fans; //粉丝数量
    @Transient
    private Long attentionSize;//关注数量

    @Transient
    private boolean isAttention;
    @Transient
    private Boolean liveRoomSupperManager;
    //高亮显示关键词
    @Transient
    private String highlightKeyWord;


    public boolean isAttention() {
        return isAttention;
    }

    public void setAttention(boolean attention) {
        isAttention = attention;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public User() {
    }

    public User(String uId, String username, String password, String payPassword, Integer payLimit, String nick, String avatar, String area, Integer gender, String phone, String email, Date created, Date updated, Date birthday, Double contributionAmount, Double balance, LatLng latLng, String aliUid, String initialLetter) {
        this.uId = uId;
        this.username = username;
        this.password = password;
        this.payPassword = payPassword;
        this.payLimit = payLimit;
        this.nick = nick;
        this.avatar = avatar;
        this.area = area;
        this.gender = gender;
        this.phone = phone;
        this.email = email;
        this.created = created;
        this.updated = updated;
        this.birthday = birthday;
        this.donationAmount = contributionAmount;
        this.balance = balance;
        this.latLng = latLng;
        this.aliUid = aliUid;
        this.initialLetter = initialLetter;
    }

    public User(String uId) {
        this.uId = uId;
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId;
    }

    public String getInitialLetter() {
        if (initialLetter == null) {
            // EaseCommonUtils.setUserInitialLetter(this);
        }
        return initialLetter;
    }

    /**
     * initial letter for nickname
     */
    protected String initialLetter;

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Double getDeposit() {
        return deposit;
    }

    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }

    public LatLng getLatLng() {
        return latLng;
    }

    public void setLatLng(LatLng latLng) {
        this.latLng = latLng;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public String getPayPassword() {
        return payPassword;
    }

    public void setPayPassword(String payPassword) {
        this.payPassword = payPassword;
    }

    public Integer getPayLimit() {
        return payLimit;
    }

    public void setPayLimit(Integer payLimit) {
        this.payLimit = payLimit;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public void setInitialLetter(String initialLetter) {
        this.initialLetter = initialLetter;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    @Override
    public String toString() {
        return nick == null ? username : nick;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public List<OrderReceiveInfo> getOrderReceiveInfoList() {
        return OrderReceiveInfoList;
    }

    public void setOrderReceiveInfoList(List<OrderReceiveInfo> orderReceiveInfoList) {
        OrderReceiveInfoList = orderReceiveInfoList;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }


    public String getUId() {
        return this.uId;
    }

    public void setUId(String uId) {
        this.uId = uId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Double getBalance() {
        return balance;
    }

    public Double getDonationAmount() {
        return donationAmount;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    public String getAliUid() {
        return aliUid;
    }

    public void setAliUid(String aliUid) {
        this.aliUid = aliUid;
    }

    public String getAliAccount() {
        return aliAccount;
    }

    public void setAliAccount(String aliAccount) {
        this.aliAccount = aliAccount;
    }

    public Boolean getLiveRoomSupperManager() {
        return liveRoomSupperManager;
    }

    public void setLiveRoomSupperManager(Boolean liveRoomSupperManager) {
        this.liveRoomSupperManager = liveRoomSupperManager;
    }

    public Long getFans() {
        return fans;
    }

    public void setFans(Long fans) {
        this.fans = fans;
    }

    public Long getAttentionSize() {
        return attentionSize;
    }

    public void setAttentionSize(Long attentionSize) {
        this.attentionSize = attentionSize;
    }

    public String getHighlightKeyWord() {
        return highlightKeyWord;
    }

    public void setHighlightKeyWord(String highlightKeyWord) {
        this.highlightKeyWord = highlightKeyWord;
    }

    @Keep
    public User(String uId, String username, String nick, String avatar, String area, Integer gender, String phone, String email, Date created, Date updated, Date birthday, Double donationAmount, Integer status, Integer type, String initialLetter) {
        this.uId = uId;
        this.username = username;
        this.nick = nick;
        this.avatar = avatar;
        this.area = area;
        this.gender = gender;
        this.phone = phone;
        this.email = email;
        this.created = created;
        this.updated = updated;
        this.birthday = birthday;
        this.donationAmount = donationAmount;
        this.status = status;
        this.type = type;
        this.initialLetter = initialLetter;
    }

    public void setDonationAmount(Double donationAmount) {
        this.donationAmount = donationAmount;
    }

    public Integer getStatus() {
        return this.status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getType() {
        return this.type;
    }

    public void setType(Integer type) {
        this.type = type;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.uId);
        dest.writeString(this.username);
        dest.writeString(this.password);
        dest.writeString(this.payPassword);
        dest.writeValue(this.payLimit);
        dest.writeString(this.nick);
        dest.writeString(this.avatar);
        dest.writeString(this.area);
        dest.writeTypedList(this.OrderReceiveInfoList);
        dest.writeValue(this.gender);
        dest.writeString(this.phone);
        dest.writeString(this.email);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.birthday != null ? this.birthday.getTime() : -1);
        dest.writeValue(this.donationAmount);
        dest.writeValue(this.status);
        dest.writeValue(this.type);
        dest.writeString(this.token);
        dest.writeValue(this.balance);
        dest.writeValue(this.deposit);
        dest.writeParcelable(this.latLng, flags);
        dest.writeString(this.aliUid);
        dest.writeString(this.aliAccount);
        dest.writeValue(this.fans);
        dest.writeValue(this.attentionSize);
        dest.writeByte(this.isAttention ? (byte) 1 : (byte) 0);
        dest.writeValue(this.liveRoomSupperManager);
        dest.writeString(this.highlightKeyWord);
        dest.writeString(this.initialLetter);
    }

    protected User(Parcel in) {
        this.uId = in.readString();
        this.username = in.readString();
        this.password = in.readString();
        this.payPassword = in.readString();
        this.payLimit = (Integer) in.readValue(Integer.class.getClassLoader());
        this.nick = in.readString();
        this.avatar = in.readString();
        this.area = in.readString();
        this.OrderReceiveInfoList = in.createTypedArrayList(OrderReceiveInfo.CREATOR);
        this.gender = (Integer) in.readValue(Integer.class.getClassLoader());
        this.phone = in.readString();
        this.email = in.readString();
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpBirthday = in.readLong();
        this.birthday = tmpBirthday == -1 ? null : new Date(tmpBirthday);
        this.donationAmount = (Double) in.readValue(Double.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.token = in.readString();
        this.balance = (Double) in.readValue(Double.class.getClassLoader());
        this.deposit = (Double) in.readValue(Double.class.getClassLoader());
        this.latLng = in.readParcelable(LatLng.class.getClassLoader());
        this.aliUid = in.readString();
        this.aliAccount = in.readString();
        this.fans = (Long) in.readValue(Long.class.getClassLoader());
        this.attentionSize = (Long) in.readValue(Long.class.getClassLoader());
        this.isAttention = in.readByte() != 0;
        this.liveRoomSupperManager = (Boolean) in.readValue(Boolean.class.getClassLoader());
        this.highlightKeyWord = in.readString();
        this.initialLetter = in.readString();
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}
